﻿using System.Collections.Generic;
using System.Linq;

namespace Roulette
{
    public class Bet
    {
        public double Amount { get; set; }
        public Option Option { get; set; }

        public IEnumerable<Outcome> Evaluate(Outcome currentOutcome)
        {
            if ((currentOutcome.Gain - this.Amount) >= -1d)
            {
                return this.Option.Outcomes.Select(outcome => new Outcome()
                {
                    Probability = outcome.Probability * currentOutcome.Probability,
                    Gain = (outcome.Gain * this.Amount) + currentOutcome.Gain
                });
            }
            else
            {
                return new Outcome[] { currentOutcome };
            }
        }
    }
}
